home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / UPPER.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-22  |  2KB  |  70 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 294 of 310
  3. From : Norbert Igl                         2:2402/300.3         16 Apr 93  23:19
  4. To   : Max Maischein                       2:249/6.17
  5. Subj : International characters
  6. ────────────────────────────────────────────────────────────────────────────────
  7.  > Note that your uppercase characters do not include the german Umlauts
  8.  > and overlap sometimes with other foreign characters. There is a DOS
  9.  > function call to convert a string to all upcercase letters. Norbert
  10.  > Igl and I wrote a ASM implementation, maybe he could repost his all-
  11.  > Pascal version that conforms to the DOS country information.
  12.  > -max
  13.  
  14.  no problem....
  15.  
  16. -------------------------8<---------------------------------}
  17.  
  18. Unit Upper;
  19. { Country-independent upcase-procedures          (c) 1992  N.Igl
  20.  
  21.   Uses the COUNRY=??? from your CONFIG.SYS to get the correct uppercase.
  22.   SpeedUp with a table-driven version to avoid multiple DOS-Calls.
  23.  
  24.   Released to the public domain ( FIDO: PASCAL int'l ) in 12/92 }
  25.  
  26.  
  27. Interface
  28.  
  29. function UpCase   (ch:char)  : Char;
  30. function UpCaseStr( S:String): String;
  31.  
  32. Implementation uses Dos;
  33.  
  34. Const   isTableOk : Boolean = FALSE;
  35. Var     theTable  : Array[0..255] of Char;
  36.  
  37. Procedure SetUpTable;                          { called only at Unit-init }
  38. var Regs: Registers;
  39.     x   : byte;
  40. begin
  41.   FillChar( theTable, Sizeof( theTable ), #0 );{ Fill with NULL }
  42.   For x := 1 to 255 do theTable[x] := CHAR(x); { predefined values }
  43.   if Lo(DosVersion) < 4 then                   { n/a in this DOS... }
  44.   begin                                        { use Turbo's Upcase }
  45.     for x := 1 to 255 do
  46.       theTable[x] := System.Upcase(CHAR(x));
  47.     exit;
  48.   end;
  49.   Regs.AX := $6521;                            { "Capitalize String" }
  50.   Regs.CX := 255;                              { "string"-length }
  51.   Regs.DS := Seg(theTable);                    { DS:DX... }
  52.   Regs.DX := Ofs(theTable[1]);                 {  ...points to the "string"}
  53.   Intr($21,Regs);                              { let DOS do it ! }
  54.   isTableOK := ( Regs.Flags and FCarry = 0 );  { OK ? }
  55. end;
  56.  
  57. function UpCase( ch:char ):char;
  58. begin
  59.   UpCase := theTable[BYTE(ch)]
  60. end;
  61.  
  62. function UpCaseStr(S:String):String;
  63. var x: Byte;
  64. begin
  65.   for x := 1 to length(S) do
  66.      S[x]:= theTable[BYTE(S[x])];
  67.  UpCaseStr := S
  68. end;
  69.  
  70. begin SetUpTable end.